package com.huaxin.hxcloud.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.huaxin.common.BaseActivity;
import com.huaxin.common.Entity.UserDTO;
import com.huaxin.hxcloud.R;
import com.huaxin.hxcloud.fragment.GenCodeFragment;
import com.huaxin.hxcloud.fragment.HxIntroFragment;
import com.huaxin.hxcloud.fragment.ModifyNameFragment;
import com.huaxin.hxcloud.fragment.ModifySexFragment;
import com.huaxin.hxcloud.fragment.UserInfoFragment;

import java.lang.ref.WeakReference;

/**
 * Created by Administrator on 2017/3/3.
 */

public class ModifyUserInfoActivity extends BaseActivity {
    private static final String TAG = "ModifyUserInfoActivity";
    private UserDTO                 _user;
    private int                     mPageValue;
    private WeakReference<Fragment> mFragment;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_modify_user_info;
    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        Fragment fragment = new UserInfoFragment();
        getSupportFragmentManager().beginTransaction()
                //                .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_left,
                //                        R.anim.slide_in_from_left, R.anim.slide_out_to_right)
                .replace(R.id.container, fragment)
                .addToBackStack(null)
                .commit();
    }

    public void startModifyNameFragment() {
        Fragment fragment = new ModifyNameFragment();
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_left,
                        R.anim.slide_in_from_left, R.anim.slide_out_to_right)
                .replace(R.id.container, fragment)
                .addToBackStack(null)
                .commit();
    }

    public void startModifySexFragment() {
        Fragment fragment = new ModifySexFragment();
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_left,
                        R.anim.slide_in_from_left, R.anim.slide_out_to_right)
                .replace(R.id.container, fragment)
                .addToBackStack(null)
                .commit();
    }

    public void startGenCodeFragment() {
        Fragment fragment = new GenCodeFragment();
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_left,
                        R.anim.slide_in_from_left, R.anim.slide_out_to_right)
                .replace(R.id.container, fragment)
                .addToBackStack(null)
                .commit();
    }

    /**
     * 简介
     */
    public void startIntroFragment() {
        Fragment fragment = new HxIntroFragment();
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_left,
                        R.anim.slide_in_from_left, R.anim.slide_out_to_right)
                .replace(R.id.container, fragment)
                .addToBackStack(null)
                .commit();
    }

    @Override
    public void onBackPressed() {
        if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
            finish();
        } else {
            super.onBackPressed();
        }
    }


}
